]> git.vomp.tv Git - vompclient-marten.git/commitdiff
Preparation for AC3 and Mute and Volume Control
authorMarten Richter <marten.richter@freenet.de>
Sun, 14 Oct 2012 16:34:54 +0000 (18:34 +0200)
committerMarten Richter <marten.richter@freenet.de>
Sun, 14 Oct 2012 16:34:54 +0000 (18:34 +0200)
audioomx.cc
remotelinux.cc

index 03ac225837944c6170af71690a046a47baa4be1c..0824869feb6dbe588c9ef12cba02282552a0e597 100644 (file)
@@ -481,6 +481,7 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
        Log::getInstance()->log("Audio", Log::DEBUG,
                                                        "ChangeAudioPortConfig");
 
+       OMX_AUDIO_CODINGTYPE encoding;
        if (hdmi) {
                switch (lastAType) {
                case MPTYPE_MPEG_AUDIO: {
@@ -489,8 +490,11 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
                        } else {
                                if (prefered_mp2 == 2 && canpass_mp2) {
                                        passthrough = true;
-                               } else
+                                       encoding=OMX_AUDIO_CodingMP3;
+                               } else {
                                        passthrough = false;
+                                       encoding=OMX_AUDIO_CodingPCM;
+                               }
                        }
                }
                        break;
@@ -501,8 +505,11 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
                        } else {
                                if (prefered_ac3 == 2 && canpass_ac3) {
                                        passthrough = true;
-                               } else
+                                       encoding=OMX_AUDIO_CodingDDP;
+                               } else {
                                        passthrough = false;
+                                       encoding=OMX_AUDIO_CodingPCM;
+                               }
                        }
                }
                        break;
@@ -512,14 +519,18 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
                        } else {
                                if (prefered_mp3 == 2 && canpass_mp2) {
                                        passthrough = true;
-                               } else
+                                       encoding=OMX_AUDIO_CodingMP3;
+                               } else {
                                        passthrough = false;
+                                       encoding=OMX_AUDIO_CodingPCM;
+                               }
                        }
                }
                        break;
                };
        } else {
                 passthrough=false;
+                encoding=OMX_AUDIO_CodingPCM;
                 //mch=false; // multichannel also false
        }
 
@@ -546,6 +557,31 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
 
 
        if (!omx_running) {
+               OMX_AUDIO_PARAM_PORTFORMATTYPE format;
+               memset(&format, 0, sizeof(format));
+               format.nSize = sizeof(format);
+               format.nVersion.nVersion = OMX_VERSION;
+               format.nPortIndex = omx_rend_input_port;
+               error = OMX_GetParameter(omx_aud_rend, OMX_IndexParamAudioPortFormat,
+                               &format);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Audio", Log::DEBUG,
+                                       "Get OMX_IndexParamAudioPortFormat failed %x %d", error,
+                                       omx_rend_input_port);
+                       return 0;
+               }
+
+               format.eEncoding = encoding;
+
+               error = OMX_SetParameter(omx_aud_rend, OMX_IndexParamAudioPortFormat,
+                               &format);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Audio", Log::DEBUG,
+                                       "Set OMX_IndexParamAudioPortFormat failed %x %d", error,
+                                       omx_rend_input_port);
+                       return 0;
+               }
+
                if (passthrough) {
                        // TODO coding
                } else {
@@ -560,6 +596,9 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
                                video->DisablePort(omx_aud_rend,omx_rend_input_port,false);
                                DestroyInputBufsOMX();
                        }*/
+
+
+
                        OMX_AUDIO_PARAM_PCMMODETYPE audio_pcm;
                        memset(&audio_pcm, 0, sizeof(audio_pcm));
                        audio_pcm.nSize = sizeof(audio_pcm);
@@ -582,7 +621,6 @@ int AudioOMX::ChangeAudioPortConfig(bool disport) //clock aka omx mutex needs to
                                Log::getInstance()->log("Audio", Log::DEBUG,
                                                "Init OMX_IndexParamAudioPcm failed %x %d", error,
                                                omx_rend_input_port);
-                               //DeAllocateCodecsOMX();
                                return 0;
                        }
                        /*if (disport) {
@@ -885,6 +923,7 @@ int AudioOMX::AllocateCodecsOMX()
        video->UnlockClock();
        paused=false;
        omx_running=true;
+       setVolume(volume);
 
 
        if (!video->setClockExecutingandRunning()) return 0;
@@ -1143,23 +1182,58 @@ int AudioOMX::stop()
   return 1;
 }
 
-int AudioOMX::mute()
-{
-  if (!initted) return 0;
-
-//  if (ioctl(fdAudio, AV_SET_AUD_MUTE, 1) != 0) return 0;
-  Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE");
+int AudioOMX::mute() {
+       if (!initted)
+               return 0;
+       Log::getInstance()->log("Audio", Log::DEBUG, "MUTE MUTE MUTE");
+       if (omx_running) {
+               VideoOMX *vw = (VideoOMX*) Video::getInstance();
+               vw->LockClock();
+               OMX_AUDIO_CONFIG_MUTETYPE amute;
+               memset(&amute, 0, sizeof(amute));
+               amute.nSize = sizeof(amute);
+               amute.nVersion.nVersion = OMX_VERSION;
+               amute.nPortIndex = omx_rend_input_port;
+               amute.bMute = OMX_TRUE;
+               OMX_ERRORTYPE error= OMX_SetParameter(omx_aud_rend, OMX_IndexConfigAudioMute,
+                                               &amute);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Audio", Log::DEBUG,
+                                       "Set OMX_IndexConfigAudioMute failed %x %d", error,
+                                       omx_rend_input_port);
+                       return 0;
+               }
+               vw->UnlockClock();
+       }
 
-  muted = 1;
-  return 1;
+       muted = 1;
+       return 1;
 }
 
 int AudioOMX::unMute()
 {
   if (!initted) return 0;
 
-//  if (ioctl(fdAudio, AV_SET_AUD_MUTE, 0) != 0) return 0;
   Log::getInstance()->log("Audio", Log::DEBUG, "MUTE OFF OFF OFF");
+  if (omx_running) {
+               VideoOMX *vw = (VideoOMX*) Video::getInstance();
+               vw->LockClock();
+               OMX_AUDIO_CONFIG_MUTETYPE amute;
+               memset(&amute, 0, sizeof(amute));
+               amute.nSize = sizeof(amute);
+               amute.nVersion.nVersion = OMX_VERSION;
+               amute.nPortIndex = omx_rend_input_port;
+               amute.bMute = OMX_FALSE;
+               OMX_ERRORTYPE error = OMX_SetParameter(omx_aud_rend, OMX_IndexConfigAudioMute,
+                                               &amute);
+               if (error != OMX_ErrorNone) {
+                       Log::getInstance()->log("Audio", Log::DEBUG,
+                                       "Set OMX_IndexConfigAudioMute failed %x %d", error,
+                                       omx_rend_input_port);
+                       return 0;
+               }
+               vw->UnlockClock();
+       }
 
   muted = 0;
   return 1;
@@ -1231,25 +1305,31 @@ int AudioOMX::setVolume(int tvolume)
 // Right, that one was rubbish... 0-10 were almost
 // inaudible, 11-20 did what should have been done
 // over the whole 0-20 range
+  volume=tvolume;
+
+
+
+  if (omx_running) {
+         VideoOMX *vw = (VideoOMX*) Video::getInstance();
+         vw->LockClock();
+         OMX_AUDIO_CONFIG_VOLUMETYPE avol;
+         memset(&avol, 0, sizeof(avol));
+         avol.nSize = sizeof(avol);
+         avol.nVersion.nVersion = OMX_VERSION;
+         avol.nPortIndex = omx_rend_input_port;
+         avol.bLinear=OMX_FALSE;
+         avol.sVolume.nValue =(volume-20)*200;
+         OMX_ERRORTYPE error = OMX_SetParameter(omx_aud_rend, OMX_IndexConfigAudioVolume,
+                         &avol);
+         if (error != OMX_ErrorNone) {
+                 Log::getInstance()->log("Audio", Log::DEBUG,
+                                 "Set OMX_IndexConfigAudioVolume failed %x %d", error,
+                                 omx_rend_input_port);
+                 return 0;
+         }
+         vw->UnlockClock();
+  }
 
-  tvolume = 20 - tvolume;
-
-  audio_volume Avolume;
-  Avolume.frontleft = tvolume + Aoffset.frontleft;
-  Avolume.frontright = tvolume + Aoffset.frontright;
-  Avolume.rearleft = tvolume + Aoffset.rearleft;
-  Avolume.rearright = tvolume + Aoffset.rearright;
-  Avolume.center = tvolume + Aoffset.center;
-  Avolume.lfe = tvolume + Aoffset.lfe;
-
-//  if (ioctl(fdAudio, AV_SET_AUD_VOLUME, &Avolume) != 0) return 0;
-
-//  unsigned long vol = (tvolume << 24) | (tvolume << 16);
-//
-//  Log::getInstance()->log("Audio", Log::DEBUG, "%lx", vol);
-//  Log::getInstance()->log("Audio", Log::DEBUG, "%i", tvolume);
-
-//  if (ioctl(fdAudio, AV_SET_AUD_VOLUME, &vol) != 0) return 0;
   return 1;
 }
 
index 221a18aacf1f2be4688eb0992957bb281ecb3dd6..8d300f01a477d746883e6ae202e48ab3aefa2e2f 100644 (file)
@@ -430,8 +430,9 @@ void RemoteLinux::InitHWCListwithDefaults()
     translist[W_G_HCW(W_HCW_KC,KEY_BACK)] = REVERSE;
     translist[W_G_HCW(W_HCW_KC,KEY_T)] = REVERSE;
     translist[W_G_HCW(W_HCW_KC,KEY_MUTE)] = MUTE;
-    translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEUP;
-    translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEDOWN;
+    translist[W_G_HCW(W_HCW_KC,KEY_F8)] = MUTE;
+    translist[W_G_HCW(W_HCW_KC,KEY_F10)] = VOLUMEUP;
+    translist[W_G_HCW(W_HCW_KC,KEY_F9)] = VOLUMEDOWN;
     translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEUP)] = VOLUMEUP;
     translist[W_G_HCW(W_HCW_KC,KEY_VOLUMEDOWN)] = VOLUMEDOWN;
     translist[W_G_HCW(W_HCW_KC,KEY_CHANNELUP)] = CHANNELUP;