samsung google for best app android audio-recording

android - google - Intentando grabar audio, pero aparece el mensaje "Mediarecorder se fue con eventos no controlados" y "Fatal signal 11(SIGSEGV)..."



samsung voice recorder (4)

Esto podría surgir debido a la ejecución de firmware modded. Un SIGSEGV no debería ser posible desde Java. Lee este post. Hay una explicación del error al final. Buena suerte.

Error de Android SIGSEGV al grabar audio

Estoy tratando de grabar audio en Android pero estoy enfrentando un problema.

Tengo los botones de inicio y parada, "inicio" para iniciar la grabación y "detener" para detener la grabación.

El problema es que cuando presiono el botón de detener, mi aplicación registra un mensaje "W / MediaRecorder (635): el mediarecorder desapareció con eventos no controlados". (La función de inicio es guardar el archivo de audio correctamente).

Luego, si vuelvo a presionar el botón de inicio o detención, aparece el mensaje de error "A / libc (743): señal fatal 11 (SIGSEGV) en 0x00000010 (código = 1), hilo 743 (xample.recorder)"

El código de la clase de grabación está abajo:

/** * Creates a new audio recording at the given path (relative to root of SD card). */ public AudioRecorder(String path) { this.path = sanitizePath(path); } private String sanitizePath(String path) { if (!path.startsWith("/")) { path = "/" + path; } if (!path.contains(".")) { path += ".3gp"; } return Environment.getExternalStorageDirectory().getAbsolutePath() + path; } public void start() throws IOException { String state = android.os.Environment.getExternalStorageState(); if(!state.equals(android.os.Environment.MEDIA_MOUNTED)) { throw new IOException("SD Card is not mounted. It is " + state + "."); } // make sure the directory we plan to store the recording in exists File directory = new File(path).getParentFile(); if (!directory.exists() && !directory.mkdirs()) { throw new IOException("Path to file could not be created."); } recorder.setAudioSource(MediaRecorder.AudioSource.MIC); recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP); recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB); recorder.setOutputFile(path); try{ recorder.prepare(); } catch(IOException e){ Log.e("Recorder","Recording failed"); } recorder.start(); } /** * Stops a recording that has been previously started. */ public void stop() throws IOException { recorder.stop(); recorder.release(); }

El código de actividad principal se encuentra a continuación:

/* * */ public class Recorder extends Activity implements OnClickListener { private static final String TAG="Recorder"; AudioRecorder ar=new AudioRecorder("/TestAudio.3gp"); @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_recorder); final Button start = (Button) this.findViewById(R.id.btn_start); start.setOnClickListener(this); final Button stop = (Button) this.findViewById(R.id.btn_stop); stop.setOnClickListener(this); } @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_recorder, menu); return true; } public void onClick(View v) { // TODO Auto-generated method stub try{ switch (v.getId()) { case R.id.btn_start: ar.start(); Log.d("Recorder","Recorded"); Toast.makeText(this, "Controll returned from start function", Toast.LENGTH_LONG).show(); break; case R.id.btn_stop: ar.stop(); Toast.makeText(this, "Recording stopped; Starting MediaPlayer", Toast.LENGTH_SHORT).show(); //Toast.makeText(this, "Starting media player", Toast.LENGTH_LONG).show(); ar.startPlaying(); //Toast.makeText(this, "Recording stopped", Toast.LENGTH_LONG).show(); break; } } catch(Exception e){ Log.e("Recorder", e.getMessage(), e); Toast.makeText(this, e.getMessage(), Toast.LENGTH_LONG).show(); } }

}


La documentación establece:

Para recibir la respectiva devolución de llamada asociada con estos escuchas, se requieren aplicaciones para crear objetos MediaRecorder en subprocesos con un Looper en ejecución (el subproceso principal de la interfaz de usuario ya tiene un Looper en ejecución de manera predeterminada).

Asegúrese de crear la grabadora en el subproceso de la interfaz de usuario. Tal vez también llame a sus métodos en el hilo de la interfaz de usuario.


Resolví este problema reiniciando la grabadora antes de soltarla.

recorder.stop(); // stop recording recorder.reset(); // set state to idle recorder.release(); // release resources back to the system recorder = null;


Tengo Android 4.0.4 (y por mi versión no modificada de Samsung, le he hecho cambios) en mi Samsung Galaxy S3 y algunas veces puedo obtener un SIGSEGV ("A / libc (20448): Fatal signal 11 (SIGSEGV) en 0x00000010 (código = 1) ") cuando uso la grabadora mediar.

También tengo un SIGSEGV en mi AVD para Android 4.0, por lo que es posible obtener un SIGSEGV incluso allí.

Ahora solo tengo que encontrar lo que hago mal con el mediarecorder. =)