📄 audio_dialog.cpp
字号:
/* * The contents of this file are subject to the Mozilla Public * License Version 1.1 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.mozilla.org/MPL/ * * Software distributed under the License is distributed on an "AS * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or * implied. See the License for the specific language governing * rights and limitations under the License. * * The Original Code is MPEG4IP. * * The Initial Developer of the Original Code is Cisco Systems Inc. * Portions created by Cisco Systems Inc. are * Copyright (C) Cisco Systems Inc. 2001-2005. All Rights Reserved. * * Contributor(s): * Dave Mackie dmackie@cisco.com * Bill May wmay@cisco.com */#define __STDC_LIMIT_MACROS#include "mp4live.h"#include "mp4live_gui.h"#include "audio_alsa_source.h"#include "audio_oss_source.h"#include "profile_audio.h"#include "audio_encoder.h"#include "support.h"// Source dialog variablesstatic const char* inputValues[] = { "cd", "line", "mic", "mix"};static const char* inputNames[] = { "CD", "Line In", "Microphone", "Via Mixer"};static const char* inputTypes[] = { AUDIO_SOURCE_OSS, #ifdef HAVE_ALSA AUDIO_SOURCE_ALSA#endif};static bool source_modified;static CAudioCapabilities* pAudioCaps;static const char* source_type;// Profile dialog variablesstatic const char **encodingNames;static GtkWidget *AudioProfileDialog = NULL, *AudioSourceDialog = NULL;static const char** samplingRateNames = NULL;static u_int32_t* samplingRateValues = NULL;static u_int32_t samplingRateNumber = 0; // how many sampling ratesstatic const char* channelNames[] = { "1 - Mono", "2 - Stereo"};static u_int32_t *bitRateValues;static const char **bitRateNames;static u_int32_t bitRateNumber = 0; // how many bit rates/*static bool SourceIsDevice(){ GtkWidget *temp; temp = lookup_widget(AudioSourceDialog, "AudioSourceFile"); return IsDevice(gtk_entry_get_text(GTK_ENTRY(temp)));}*/#if 0static void ShowSourceSpecificSettings(){ if (SourceIsDevice()) { gtk_widget_show(input_label); gtk_widget_show(input_menu); gtk_widget_hide(track_label); gtk_widget_hide(track_menu); } else { gtk_widget_hide(input_label); gtk_widget_hide(input_menu); gtk_widget_show(track_label); gtk_widget_show(track_menu); }}#endifstatic void SourceDevice(){ GtkWidget *temp; temp = lookup_widget(AudioSourceDialog, "AudioSourceFile"); const char *newSourceName = gtk_entry_get_text(GTK_ENTRY(temp)); // don't probe the already open device!#if 0 if (!strcmp(newSourceName, MyConfig->GetStringValue(CONFIG_AUDIO_SOURCE_NAME))) { return; }#endif // probe new device GtkWidget* wid = lookup_widget(GTK_WIDGET(AudioSourceDialog), "AudioTypeMenu"); const char* source_type = inputTypes[gtk_option_menu_get_history(GTK_OPTION_MENU(wid))]; CAudioCapabilities* pNewAudioCaps; debug_message("trying source %s", source_type); if (!strcasecmp(source_type, AUDIO_SOURCE_OSS)) { pNewAudioCaps = new CAudioCapabilities(newSourceName);#ifdef HAVE_ALSA } else if (!strcasecmp(source_type, AUDIO_SOURCE_ALSA)) { pNewAudioCaps = new CALSAAudioCapabilities(newSourceName);#endif } else { return; } // check for errors if (!pNewAudioCaps->IsValid()) { ShowMessage("Change Audio Source", "Specified audio source can't be opened, check name"); delete pNewAudioCaps; return; } if (pAudioCaps != MyConfig->m_audioCapabilities) { delete pAudioCaps; } pAudioCaps = pNewAudioCaps;}static void ChangeSource(){ debug_message("In ChangeSource"); GtkWidget *wid = lookup_widget(AudioSourceDialog, "AudioSourceFile"); const char* new_source_name = gtk_entry_get_text(GTK_ENTRY(wid)); wid = lookup_widget(GTK_WIDGET(AudioSourceDialog), "AudioTypeMenu"); const char* new_source_type = inputTypes[gtk_option_menu_get_history(GTK_OPTION_MENU(wid))]; if (strcmp(new_source_name, MyConfig->GetStringValue(CONFIG_AUDIO_SOURCE_NAME)) == 0 && strcmp(new_source_type, MyConfig->GetStringValue(CONFIG_AUDIO_SOURCE_TYPE)) == 0) { return; } if (!strcmp(new_source_type, AUDIO_SOURCE_OSS)) { source_type = AUDIO_SOURCE_OSS; SourceDevice();#ifdef HAVE_ALSA } else if (!strcmp(new_source_type, AUDIO_SOURCE_ALSA)) { source_type = AUDIO_SOURCE_ALSA; SourceDevice();#endif } else { if (pAudioCaps != MyConfig->m_audioCapabilities) { delete pAudioCaps; } pAudioCaps = NULL; if (IsUrl(new_source_name)) { source_type = URL_SOURCE; } else { if (access(new_source_name, R_OK) != 0) { ShowMessage("Change Audio Source", "Specified audio source can't be opened, check name"); } source_type = FILE_SOURCE; } }#if 0 track_menu = CreateTrackMenu( track_menu, 'A', gtk_entry_get_text(GTK_ENTRY(source_entry)), &trackIndex, &trackNumber, &trackValues); ShowSourceSpecificSettings();#endif}static void on_source_browse_button (GtkWidget *widget, gpointer *data){ GtkWidget *wid = lookup_widget(AudioSourceDialog, "AudioSourceFile"); FileBrowser(wid, AudioSourceDialog, GTK_SIGNAL_FUNC(ChangeSource));}static void on_source_entry_changed(GtkWidget *widget, gpointer *data){ source_modified = true;}static int on_source_leave(GtkWidget *widget, gpointer *data){ if (source_modified) { ChangeSource(); } return FALSE;}static voidon_AudioSourceDialog_response (GtkDialog *dialog, gint response_id, gpointer user_data){ if (response_id == GTK_RESPONSE_OK) { GtkWidget *wid; wid = lookup_widget(GTK_WIDGET(dialog), "AudioSourceFile"); const char *source_name = gtk_entry_get_text(GTK_ENTRY(wid)); if (strcmp(source_name, MyConfig->GetStringValue(CONFIG_AUDIO_SOURCE_NAME)) != 0) { MyConfig->SetStringValue(CONFIG_AUDIO_SOURCE_NAME, source_name); MyConfig->SetStringValue(CONFIG_AUDIO_SOURCE_TYPE, source_type); if (MyConfig->m_audioCapabilities != pAudioCaps) { delete MyConfig->m_audioCapabilities; MyConfig->m_audioCapabilities = pAudioCaps; pAudioCaps = NULL; } } wid = lookup_widget(GTK_WIDGET(dialog), "AudioPortMenu"); MyConfig->SetStringValue(CONFIG_AUDIO_INPUT_NAME, inputValues[gtk_option_menu_get_history(GTK_OPTION_MENU(wid))]); MyConfig->Update(); MainWindowDisplaySources(); } gtk_widget_destroy(GTK_WIDGET(dialog));}void create_AudioSourceDialog (void){ GtkWidget *dialog_vbox8; GtkWidget *table6; GtkWidget *audioTypeLabel; GtkWidget *label157; GtkWidget *label158; GtkWidget *hbox77; GtkWidget *AudioSourceFile; GtkWidget *AudioSourceBrowse; GtkWidget *alignment21; GtkWidget *hbox78; GtkWidget *image21; GtkWidget *label163; GtkWidget *AudioTypeMenu; GtkWidget *AudioPortMenu; GtkWidget *dialog_action_area7; GtkWidget *AudioSourceCancel; GtkWidget *okbutton7; GtkTooltips *tooltips; tooltips = gtk_tooltips_new(); AudioSourceDialog = gtk_dialog_new(); gtk_window_set_title(GTK_WINDOW(AudioSourceDialog), _("Select Audio Source")); gtk_window_set_modal(GTK_WINDOW(AudioSourceDialog), TRUE); gtk_window_set_resizable(GTK_WINDOW(AudioSourceDialog), FALSE); gtk_window_set_transient_for(GTK_WINDOW(AudioSourceDialog), GTK_WINDOW(MainWindow)); dialog_vbox8 = GTK_DIALOG(AudioSourceDialog)->vbox; gtk_widget_show(dialog_vbox8); table6 = gtk_table_new(2, 2, FALSE); gtk_widget_show(table6); gtk_box_pack_start(GTK_BOX(dialog_vbox8), table6, TRUE, TRUE, 0); gtk_table_set_row_spacings(GTK_TABLE(table6), 2); gtk_table_set_col_spacings(GTK_TABLE(table6), 9); audioTypeLabel = gtk_label_new(_("Type:")); gtk_widget_show(audioTypeLabel); gtk_table_attach(GTK_TABLE(table6), audioTypeLabel, 0, 1, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(audioTypeLabel), 0, 0.5); label157 = gtk_label_new(_("Source:")); gtk_widget_show(label157); gtk_table_attach(GTK_TABLE(table6), label157, 0, 1, 1, 2, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label157), 0, 0.5); label158 = gtk_label_new(_("Input Port:")); gtk_widget_show(label158); gtk_table_attach(GTK_TABLE(table6), label158, 0, 1, 2, 3, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_misc_set_alignment(GTK_MISC(label158), 0, 0.5); AudioTypeMenu = gtk_option_menu_new(); gtk_widget_show(AudioTypeMenu); gtk_table_attach(GTK_TABLE(table6), AudioTypeMenu, 1, 2, 0, 1, (GtkAttachOptions)(GTK_FILL), (GtkAttachOptions)(0), 0, 0); gtk_tooltips_set_tip(tooltips, AudioTypeMenu, _("Audio Device Type"), NULL); hbox77 = gtk_hbox_new(FALSE, 0); gtk_widget_show(hbox77); gtk_table_attach(GTK_TABLE(table6), hbox77, 1, 2, 1, 2, (GtkAttachOptions)(GTK_EXPAND | GTK_FILL), (GtkAttachOptions)(GTK_FILL), 0, 0); AudioSourceFile = gtk_entry_new(); gtk_widget_show(AudioSourceFile); gtk_box_pack_start(GTK_BOX(hbox77), AudioSourceFile, TRUE, TRUE, 0); gtk_tooltips_set_tip(tooltips, AudioSourceFile, _("Select Audio Device"), NULL); AudioSourceBrowse = gtk_button_new(); gtk_widget_show(AudioSourceBrowse); gtk_box_pack_start(GTK_BOX(hbox77), AudioSourceBrowse, FALSE, FALSE, 0); alignment21 = gtk_alignment_new(0.5, 0.5, 0, 0); gtk_widget_show(alignment21);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -